package com.example.leetdemo.process;

import com.example.leetdemo.utils.DateUtils;

import java.time.LocalDateTime;
import java.util.Arrays;
import java.util.List;

public class Solution135 {

    public int candy(int[] ratings) {
        int candy = 0, f = 0, count = 0, latest = 1, l = ratings[0];
        int[][] gudi = new int[ratings.length][2];
        for (int i = 0; i < ratings.length; ) {
            if (i == ratings.length - 1) {
                gudi[i][1] = 0;
            } else {
                int rank = 1;
                for (int j = i + 1; j < ratings.length; j++) {
                    if (ratings[j] > ratings[j - 1]) {
                        rank++;
                    } else {
                        gudi[i][1] = rank;
                        i = j - 1;
                        break;
                    }
                    if (j == ratings.length - 1) {
                        gudi[i][1] = rank;
                    }
                }
            }
            i++;
        }
        for (int i = ratings.length - 1; i >= 0; ) {
            if (i == 0) {
                gudi[i][0] = 0;
            } else {
                int rank = 0;
                for (int j = i - 1; j >= 0; j--) {
                    if (ratings[j] > ratings[j + 1]) {
                        rank++;
                    } else {
                        gudi[i][0] = rank;
                        i = j + 1;
                        break;
                    }
                    if (j == 0) {
                        gudi[i][0] = rank + 1;
                    }
                }
            }
            i--;
        }
        for (int i = 0; i < ratings.length; i++) {
            if (gudi[i][0] == 0) {

            }
        }

        return ratings.length;
    }

    public static void main(String[] args) {
        String endMonth = "2024-09";

        String beginMonth = DateUtils.format(
                DateUtils.parse(endMonth + "-01 00:00:00").minusMonths(11)).substring(0, 7);
        System.err.println(beginMonth);
        System.err.println(endMonth.substring(5,7));
        LocalDateTime now = LocalDateTime.now();
        System.err.println(now.getMinute() + now.getHour() * 60);
        tttt();
        System.err.println(LocalDateTime.now().getYear());
        System.err.println("1.4.2".compareTo("1.4.20"));

        long overflowSeconds = DateUtils.localDateTimeToMilli(now) / 1000 % 300;
        System.err.println("冻结数据修复");
        for (int i = 1; i <= 7; i++) {
            String endTime = DateUtils.format(now.minusSeconds(overflowSeconds).minusMinutes(5 * (i - 1)));
            String beginTime = DateUtils.format(now.minusSeconds(overflowSeconds).minusSeconds(300 * (i)));
            System.err.println(beginTime + "----" + endTime);
        }

        String a = "ab";
        String b = "ab";
        System.err.println(a.equals(b));
        String c = "abab";
        String d = a + b;
        String e = "ab" + "ab";
        System.err.println(c == d);
        System.err.println(e == c);
    }

    private static void tttt() {
        Integer fre = 0;
        LocalDateTime beginTime = DateUtils.parse("2024-07-30 08:50:00");
        LocalDateTime endTime = DateUtils.parse("2024-10-22 08:50:00");

        LocalDateTime now = LocalDateTime.now();
        LocalDateTime startTime = beginTime;
        for (LocalDateTime temp = beginTime; temp.compareTo(endTime) <= 0; ) {
            if (now.compareTo(temp) < 0 && fre == 0) {
                startTime = temp;
            }
            if (now.compareTo(temp) <= 0) {
                fre++;
            }

            temp = temp.plusWeeks(1);

        }
        fre = fre == 0 ? 1 : fre;
        System.err.println(fre);
        System.err.println(startTime);
        String dayRecord = DateUtils.getCurrentDayRecord().substring(5, 10);
        System.err.println(dayRecord);
    }


    // 写一个函数 输入两个正整数 返回他们的最大公约数


}
